#pragma once
#include "stdafx.h"


class PSysFromScript
{
public:


	
	PSysFromScript(Ogre::Vector3 position, Ogre::SceneManager* sm, Ogre::String scriptname, std::deque<Ogre::ParticleSystem*> *pSystems)
	{
		static int id = 0;

		Ogre::SceneNode* sysNode = sm->getRootSceneNode()->createChildSceneNode();
		Ogre::ParticleSystem* psys = sm->createParticleSystem("psys"+Ogre::StringConverter::toString(id), scriptname);
		sysNode->attachObject(psys);
		sysNode->setPosition(position);


		bool isRepeat = false;
		for(short i = 0;i< psys->getNumEmitters();i++)
		{
			if(psys->getEmitter(i)->getRepeatDelay()!=0 || psys->getEmitter(i)->getMinRepeatDelay()!=0 ||(psys->getEmitter(i)->getDuration()==0 && psys->getEmitter(i)->getMaxDuration()==0))
			{
				isRepeat = true;
			}
		}

		if(!isRepeat)
		{
			pSystems->push_front(psys);
		}

		id++;
	}

	PSysFromScript(Ogre::SceneNode *node, Ogre::SceneManager* sm, Ogre::String scriptname, std::deque<Ogre::ParticleSystem*> *pSystems)
	{
		static int id = 0;

		Ogre::ParticleSystem* psys = sm->createParticleSystem("psysAttachedToNode"+Ogre::StringConverter::toString(id), scriptname);
		node->attachObject(psys);


		bool isRepeat = false;
		for(short i = 0;i< psys->getNumEmitters();i++)
		{
			if(psys->getEmitter(i)->getRepeatDelay()!=0 || psys->getEmitter(i)->getMinRepeatDelay()!=0 || (psys->getEmitter(i)->getDuration()==0 && psys->getEmitter(i)->getMaxDuration()==0))
			{
				isRepeat = true;
			}
		}

		if(!isRepeat)
		{
			pSystems->push_front(psys);
		}
		
		//sm->getP

		id++;
	}


};
